home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / SHARED.DIR / 03083_Script_PRINT LEO II A < prev    next >
Text File  |  1996-04-01  |  8KB  |  275 lines

  1. -- --------------------------------------------------------------------------------------
  2. -- Handler doClickPrintButton hilites the print button and then calls the appropriate
  3. -- print handler (depending on the given printType).
  4.  
  5. on doClickPrintButton printType, source, title, caption
  6.   puppetTransition 0
  7.   sound stop 1
  8.   --  sound stop 2
  9.   
  10.   global printSize
  11.   
  12.   hiliteButton(1,0)
  13.   
  14.   if printingInvention() then
  15.     showPrintDialog
  16.     
  17.     if (printSize = "all") then
  18.       --      printAllCards
  19.     else  if (printSize = 0) then
  20.       -- they clicked outside the dialog box, cancelling the printing
  21.       dontpassevent
  22.       exit
  23.     end if
  24.   else
  25.     set printSize = "full"
  26.   end if
  27.   
  28.   if (printType = "stage") then
  29.     -- print the stage in <printsize>
  30.     printScreen(printSize)
  31.   else if (printType = "file") then
  32.     -- print the file in <printsize>
  33.     printFile(printSize, source)
  34.   else if (printType = "picture") then
  35.     -- print the cast in <printsize>
  36.     printPicture(printSize, source, title, caption)
  37.   else if (printType = "database") then
  38.     -- print the text or picture of the current topic
  39.     printDatabase
  40.   end if
  41.   
  42.   dontpassevent
  43. end
  44.  
  45. -- --------------------------------------------------------------------------------------
  46. -- Handler printScreen calls the appropriate print screen handler (depending on the
  47. -- machine type).
  48.  
  49. on printScreen printSize
  50.   if (the machineType = 256) then
  51.     -- PC
  52.     printScreenPC(printSize)
  53.   else
  54.     printScreenMAC(printSize)
  55.   end if
  56. end
  57. -- --------------------------------------------------------------------------------------
  58. -- Handler printFile 
  59.  
  60. on printFile printSize, fileName
  61.   if (the machineType = 256) then
  62.     set divider = "\"  -- Ephraim. Second time I'm fixing it!!!!
  63.   else
  64.     set divider = ":"
  65.   end if
  66.   
  67.   set fullFileName = the pathName & "PrtPicts" & divider & fileName
  68.   
  69.   if (the machineType = 256) then
  70.     -- PC
  71.     printFilePC(printSize, fullFileName)
  72.   else
  73.     printFileMAC(printSize, fullFileName)
  74.   end if
  75. end
  76.  
  77. -- --------------------------------------------------------------------------------------
  78. -- Handler printAllCards 
  79.  
  80. on printAllCards
  81.   if (the machineType = 256) then
  82.     set divider = "\" -- Ephraim. Second time I'm fixing it!!!!
  83.   else
  84.     set divider = ":"
  85.   end if
  86.   
  87.   set filePathName = the pathName & "PrtPicts" & divider
  88.   
  89.   if (the machineType = 256) then
  90.     -- PC
  91.     printAllCardsPC(filePathName)
  92.   else
  93.     printAllCardsMAC(filePathName)
  94.   end if
  95. end
  96.  
  97. -- --------------------------------------------------------------------------------------
  98. -- Handler printPicture 
  99.  
  100. on printPicture printSize, castName, title, caption
  101.   if (the machineType = 256) then
  102.     -- PC
  103.     printPicturePC(printSize, castName, title, caption)
  104.   else
  105.     printPictureMAC(printSize, castName, title, caption)
  106.   end if
  107. end
  108.  
  109. -- ----------------------------------------------------------------
  110. -- Handler doPrint is called when the user clicks the print button.
  111. -- It prints the a selected frame of the current section. It determines
  112. -- the frame to print by assuming that the current frame is part of a 
  113. -- section beginning with a marker. The handler gets the name of the
  114. -- previous marker and using the name, gets the name of the print frame
  115. -- associated with the marker.
  116.  
  117. on doPrint previousMarker
  118.   hiliteButton
  119.   
  120.   set theLabels = the labelList
  121.   set numLabels = the number of lines in theLabels
  122.   
  123.   repeat with i = 1 to numLabels
  124.     set currentLabel = line i of theLabels
  125.     
  126.     if (label(currentLabel) = previousMarker) then
  127.       if (currentLabel = EMPTY) then
  128.         -- print the previous printFrame
  129.         set currentLabel = line (i-1) of theLabels
  130.         exit repeat
  131.         
  132.       else -- currentLabel <> EMPTY
  133.         exit repeat
  134.       end if
  135.     end if
  136.   end repeat
  137.   
  138.   set printFrame = currentLabel && "PRT"
  139.   
  140.   set printFrameNumber = label(printFrame)
  141.   printFrom printFrameNumber, printFrameNumber
  142. end
  143.  
  144. -- ----------------------------------------------------------------
  145. -- Handler showPrintDialog is called when the user clicks the print button.
  146. -- It displays a dialogue box that asks the user if he/she wants to
  147. -- print one full-sized screen or four screens.
  148.  
  149. on showPrintDialog
  150.   global dialogSprite
  151.   global printDialogLocH, printDialogLocV
  152.   
  153.   --  puppetSprite dialogSprite, TRUE
  154.   set the castNum of sprite dialogSprite = the number of cast "print dialog"
  155.   set the locH of sprite dialogSprite = printDialogLocH
  156.   set the locV of sprite dialogSprite = printDialogLocV
  157.   updateStage
  158.   
  159.   choosePrintSize
  160. end
  161.  
  162. -- ----------------------------------------------------------------
  163. -- Handler choosePrintSize is the cast script of the choose print
  164. -- size dialog box
  165.  
  166. on choosePrintSize
  167.   
  168.   repeat while not(the mouseDown)
  169.     updateStage
  170.   end repeat
  171.   
  172.   global dialogSprite, printCardRect, printFullScreenRect, printSize
  173.   global printAllCardsRect
  174.   
  175.   -- find out where clicked
  176.   set clickPoint = point(the mouseH, the mouseV)
  177.   
  178.   if (inside(clickPoint, printCardRect)) then
  179.     set printSize = "card"
  180.   else if (inside(clickPoint, printFullScreenRect)) then
  181.     set printSize = "full"
  182.     --  else if (inside(clickPoint, printAllCardsRect)) then
  183.     --    set printSize = "all"
  184.   else -- they did not click the dialog box
  185.     set printSize = 0
  186.   end if
  187.   
  188.   removeFromStage(dialogSprite)
  189. end
  190.  
  191. -- ----------------------------------------------------------------
  192. -- Handler printDatabase is called when the user clicks the print
  193. -- button in the database.
  194.  
  195. on printDatabase
  196.   if (the machineType = 256) then
  197.     -- PC
  198.     printDatabasePC
  199.   else
  200.     printDatabaseMAC
  201.   end if
  202. end
  203.  
  204. -- ----------------------------------------------------------------
  205. -- Handler doPrintFullScreen does the actual printing of the screen.
  206. -- It receives an instance of the printomatic xobj as a parameter
  207. -- (that was created in either printScreenMAC or printScreenPC).
  208.  
  209. on doPrintFullScreen printObj, fullFileName
  210.   -- set up the object:
  211.   
  212.   printobj(mSetDocumentName, "Leonardo 2")
  213.   
  214.   -- 1) reset to page 1
  215.   printobj(mreset)
  216.   
  217.   -- 2) set landscape mode
  218.   printobj(msetlandscapemode, TRUE)
  219.   
  220.   -- 3) set the margins to as big as possible
  221.   set paperwidth = printobj(mgetpaperwidth)
  222.   set paperheight = printobj(mgetpaperheight)
  223.   
  224.   printobj(msetmargins, 0, 0, paperwidth, paperheight)
  225.   
  226.   -- 4) set the printable space to the margins
  227.   printobj(msetprintablemargins)
  228.   
  229.   set pageH = printobj(mgetpageheight)
  230.   set pageW = printobj(mgetpagewidth)
  231.   
  232.   
  233.   set left = 70
  234.   set top = 70
  235.   set right = pageW - 35
  236.   set bottom = pageH - 35
  237.   
  238.   --  put "pageW" && pageW
  239.   --  put "pageH" && pageH
  240.   --  put "paperwidth" && paperwidth
  241.   --  put "paperheight" && paperheight
  242.   --  put "left" && left
  243.   --  put "top" && top
  244.   --  put "right" && right
  245.   --  put "bottom" && bottom 
  246.   
  247.   -- 5) start a new page
  248.   printobj(mnewpage)
  249.   
  250.   if voidP(fullFileName) then -- printing the screen
  251.     -- 6a) page footer left side: copyright notice
  252.     printObj(mSetTextSize,10)
  253.     printObj(mSetTextStyle,"normal")
  254.     printObj (mSetTextJust,"left")
  255.     printObj (mDrawText,"⌐1996 SoftKey Multimedia Inc., a subsidiary of SoftKey International Inc.",left,pageH-7)
  256.     
  257.     -- 6b) put a screenShot on the page
  258.     printobj(mstagepicture, left, top, right, bottom)
  259.   else
  260.     -- 6a) put the pict of the file on the page
  261.     printObj(mpicture, fullFileName, left, top, right, bottom)
  262.     -- currently, all files printed have the copyright already
  263.   end if
  264.   
  265.   -- 7) register the xobject
  266.   printobj(mRegister, "PMAT130-013-01075")
  267.   
  268.   --  printobj(mprintpreview) -- DEBUG
  269.   -- 8) print the page
  270.   printobj(mprint)
  271.   
  272.   -- 9) get rid of the object
  273.   printobj(mdispose)
  274. end
  275.